/**
 * @version 1.8
 * @Author Djx_hmbb
 * @Date 2023/8/14 22:32
 * @注释:三个线程同时运行,输出ABC
 */
public class ThreadDemo15 {
    public static void main(String[] args) {
        //创建Object对象
        Object o1 = new Object();
        Object o2 = new Object();
        Thread t1 = new Thread(()->{
            System.out.println("A");
            synchronized (o2){
                o2.notify();
            }
        });
        Thread t2 = new Thread(()->{
            synchronized (o2){
                try {
                    o2.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

            System.out.println("B");

            synchronized (o1) {
                o1.notify();
            }
        });
        Thread t3 = new Thread(()->{
            synchronized (o1){
                try {
                    o1.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("C");
        });

        t1.start();
        t2.start();
        t3.start();

    }
}
